// License Notification
//======================================================
// Copyright (c) 2010 Channel Intelligence Inc.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// ======================================================




using System.Collections.Generic;
using CIP4.Common;

namespace CIP4.Simple
{
    /// <summary>
    /// DataProvider cache contract:
    /// The DataProvider is not required to use the cachingProvider, if it does it must abide by the following conditions
    /// 1. No open ended requests should be made to the cachingProvider
    /// 2. Host provider responsible for consistency
    ///     Two consistency models
    ///     a. Always check for the presence of an item on GetItems (open ended requests included) and return the
    ///     cached item if present
    ///     b. Always check on SaveItems for the presence of an item do a cachingProvider.SaveItems call if necessary
    /// 3. In either model
    ///     The cachingProvider will never discard dirty items
    ///     Clean items in the cachingProvider may be discarded at any time
    /// 4. Cache PurgeItems must always follow Host PurgeItems
    /// 
    /// </summary>
    public interface IDataProvider
    {
        IEnumerable<object> GetItems(CollectionType collection, IBooleanValue selectionExpression, CursorType cursor);
        void SaveItems(IEnumerable<object> items, CollectionType collection, GetSerializerDelegate getSerializer);
        void PurgeItems(IEnumerable<ExternalIDType> externalIDs, CollectionType collection, GetSerializerDelegate getSerializer);
        void PurgeItems(IBooleanValue selectionExpression, CollectionType collection, CursorType cursor);
        void DeleteCollection(CollectionType collection, LoggerDelegate logger);
        void Terminate(LoggerDelegate logger);
        SerializerKindEnum SerializerKind { get; }
    }
}
